const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('broadcast_timing_send', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    sip_ip: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "SIP服务器IP"
    },
    sip_port: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "SIP服务器端口"
    },
    user_id: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "呼叫方ID"
    },
    call_id: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "接收方ID"
    },
    name: {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: "语音名字"
    },
    create_time: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "广播创建时间"
    },
    create_start_time: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "广播播放时间"
    },
    start_time: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "当天的开始播放时间"
    },
    next_time: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "当天的下一次播放时间"
    },
    end_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "当天的结束播放时间"
    },
    create_end_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "广播结束时间"
    },
    last_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "上次广播时间"
    },
    played_times: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "已播放的次数"
    },
    interval: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "播报间隔（分钟）"
    },
    status: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "播报状态，0未播报，1已播报，-1取消，-2出错"
    },
    mode: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "广播模式，1单次广播，2定时广播"
    },
    error_tip: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: "错误提示"
    }
  }, {
    sequelize,
    tableName: 'broadcast_timing_send',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
